/**
 * Project oo_thread
 */


#ifndef _MUTEX_H
#define _MUTEX_H
#include <pthread.h>
class Mutex {
public: 
    
Mutex();
~Mutex();    
void lock();
    
void unlock();

pthread_mutex_t * getMutexptr();
    
private: 
    pthread_mutex_t _mutex;
};

class MutexLockGuard
{
public:
    MutexLockGuard(Mutex & m)
    : _mutex(m)
    {
        _mutex.lock();
    }

    ~MutexLockGuard()
    {
        _mutex.unlock();
    }

private:
    Mutex & _mutex;
};

#endif //_MUTEX_H
